package com.programming.movie.manager.impl;

import java.util.List;

import com.programming.common.exception.DAOException;
import com.programming.common.exception.ManagerException;
import com.programming.common.page.Page;
import com.programming.movie.cache.BegMovieCacheService;
import com.programming.movie.dao.BegMovieDAO;
import com.programming.movie.dataobject.BegMovie;
import com.programming.movie.manager.BegMovieManager;

public class BegMovieManagerImpl implements BegMovieManager {
	private BegMovieDAO begMovieDAO;

	public void setBegMovieDAO(BegMovieDAO begMovieDAO) {
		this.begMovieDAO = begMovieDAO;
	}

	public boolean save(BegMovie begMovie) throws ManagerException {
		try {
			this.begMovieDAO.insert(begMovie);
			BegMovieCacheService.add(begMovie);
		} catch (DAOException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public Page query(BegMovie begMovie, int start, int limit) throws ManagerException {
		try {
			this.begMovieDAO.query(begMovie, start, limit);
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return null;

	}

	@Override
	public List<BegMovie> queryList(BegMovie begMovie) throws ManagerException {
		try {
				return this.begMovieDAO.queryList(begMovie);
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public boolean delete(Long id) throws ManagerException {
		try {
			this.begMovieDAO.delete(id);
		} catch (DAOException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public BegMovie getById(Long id) throws ManagerException {
		try {
			return this.begMovieDAO.getById(id);
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return null;
	}

}
